package cn.gson.crmdemo.model.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSONArray;

import cn.gson.crmdemo.model.dao.HkDao;
import cn.gson.crmdemo.model.dao.OrderesDao;
import cn.gson.crmdemo.model.mapper.HkMapper;
import cn.gson.crmdemo.model.pojo.Getmoneyplan;
import cn.gson.crmdemo.model.pojo.Order;

@Service
@Transactional(rollbackFor=Exception.class)
public class HkService {
	@Autowired
	HkMapper hm;
	@Autowired
	HkDao hd;
	@Autowired
	OrderesDao odao;
	//查询回款计划
	public JSONArray selecthk(String planDate,String customerName,Integer isAvailability){
		return hm.selecthk(planDate,customerName,isAvailability);
		
	}
	//添加回款计划
	
	public void tjhkjl(Getmoneyplan gmp){
		hd.save(gmp);
	}
	
	//删除回款计划
	public void schkjh(Integer getplanId) {
		 hd.deleteById(getplanId);
	}
	//模糊查询
	public JSONArray selectmh(String rq){
		return hm.selectmh(rq);
	}
	//已回查询
	public JSONArray selectyh(Integer i) {
		return hm.selectyh(i);
		
	}
	//查询订单
	public JSONArray selectdd() {
		return hm.selectdd();
	}
	//修改状态
	public void xgzt(int a,int b,int o) {
		Getmoneyplan gn=hd.findById(a).get();
		Order order = odao.findById(o).get();
		order.setODstate(6);
		gn.setIsAvailability(b);
	}
	//根据客户查询
	public JSONArray selectkh(String kh) {
		return hm.selectkh(kh);
		
	};
}
